package com.imooc.springcloud;

import com.imooc.springcloud.Exception.AccessLimiterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author fankai
 * @version 1.0
 * @classname GlobalException
 * @description TODO
 * @date 2021/2/24 9:38
 **/
@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler({AccessLimiterException.class})
    public String accessLimiterException(AccessLimiterException e) {
        e.printStackTrace();
        return e.getMessage();
    }

    @ExceptionHandler({Exception.class})
    public String globalException(Exception e) {
        e.printStackTrace();
        return "服务器异常";
    }

}
